#include<iostream>
using namespace std;
void swap1(int a,int b)
{
	int temp;
	temp = a;
	a = b;
	b = temp;
};
void swap2(int &a,int &b)
{
	int temp;
	temp = a;
	a = b;
	b = temp;
};
void swap3(int *a,int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
};
void print(int a,int b)
{
	cout<<"a = "<<a<<" "<<"b = "<<b<<endl;
}
int main()
{
    int a,b;
    a = 4;
    b = 3;
    cout<<"最初情况:";
    print(a,b);

    cout<<"值传递交换:";
    swap1(a,b);
    print(a,b);

    cout<<"引用传递交换:";
    swap2(a,b);
    print(a,b);

    cout<<"指针传递交换:";
    // 交换回来
    swap3(&a,&b);
    print(a,b);
}
